local danmu__slash_yuyin = fk.CreateSkill {

  name = "#danmu__slash_yuyin",

  tags = { Skill.Compulsory, },

}

Thbattle_path="packages/thbattle/"

danmu__slash_yuyin:addEffect(fk.PreCardUse, {
  name = "#danmu__slash_yuyin",
  global = true,
  mute = true,
  priority = 10,
  can_trigger = function(self, event, target, player, data)
    local names = { "danmu__slash", "cadan__jink", "yanhui" }
    return target == player and table.contains(names, data.card.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local num
    if event==fk.PreCardUse then
      if data.card.name == "danmu__slash" or data.card.name == "cadan__jink" then
        num = player:usedCardTimes(data.card.name)
        player:addCardUseHistory(data.card.name, 1)
        room:broadcastPlaySound(Thbattle_path .. "audio/card/male/" .. data.card.name .. num % 4 + 1)
      else
        room:broadcastPlaySound(Thbattle_path .. "audio/card/male/" .. data.card.name .. math.random(3))
      end
    else
      if data.card.name == "danmu__slash" or data.card.name == "cadan__jink" then
        room:broadcastPlaySound(Thbattle_path .. "audio/card/male/" .. data.card.name .. 1)
      end
    end
  end
})
danmu__slash_yuyin:addEffect(fk.PreCardRespond, {
  name = "#danmu__slash_yuyin",
  global = true,
  mute = true,
  priority = 10,
  can_trigger = function(self, event, target, player, data)
    local names = { "danmu__slash", "cadan__jink", "yanhui" }
    return target == player and table.contains(names, data.card.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local num
    if event==fk.PreCardUse then
      if data.card.name == "danmu__slash" or data.card.name == "cadan__jink" then
        num = player:usedCardTimes(data.card.name)
        player:addCardUseHistory(data.card.name, 1)
        room:broadcastPlaySound(Thbattle_path .. "audio/card/male/" .. data.card.name .. num % 4 + 1)
      else
        room:broadcastPlaySound(Thbattle_path .. "audio/card/male/" .. data.card.name .. math.random(3))
      end
    else
      if data.card.name == "danmu__slash" or data.card.name == "cadan__jink" then
        room:broadcastPlaySound(Thbattle_path .. "audio/card/male/" .. data.card.name .. 1)
      end
    end
  end
})

return danmu__slash_yuyin